﻿<!--
    Author   JO Hyeong-Ryeol
    Since	2013.06.02

    This file is a part of the Nicenis project.
    https://nicenis.codeplex.com
    
    Copyright (C) 2013 JO Hyeong-Ryeol. All rights reserved.   
-->
<Window x:Class="NicenisTestGui.DragMoverTestWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:n="clr-namespace:Nicenis.Windows;assembly=Nicenis"
        Title="DragMoverTestWindow" Height="500" Width="924"
        >
    <Grid Margin="10">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*" />
            <ColumnDefinition Width="*" />
        </Grid.ColumnDefinitions>

        <Grid.RowDefinitions>
            <RowDefinition Height="100" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>


        <!-- The DragMover that moves this window. -->
        <n:DragMover
            x:Name="windowMover"
            Grid.Column="0"
            Grid.Row="0"
            Target="{Binding RelativeSource={RelativeSource AncestorType=Window}}"
            Background="Red"
            Margin="10"
            >
            <TextBlock
                FontSize="14"
                HorizontalAlignment="Center"
                VerticalAlignment="Center"
                IsHitTestVisible="False"
                >
                <TextBlock.Text>
                    <MultiBinding StringFormat="Drag this element to move this window.&#10;[{0,7:0.0},{1,7:0.0}]">
                        <Binding Path="Target.Left" ElementName="windowMover" />
                        <Binding Path="Target.Top" ElementName="windowMover" />
                    </MultiBinding>
                </TextBlock.Text>
            </TextBlock>
        </n:DragMover>


        <!-- The DragMover that moves this window within the Desktop area. -->
        <n:DragMover
            x:Name="windowWithinWorkAreaMover"
            Grid.Column="1"
            Grid.Row="0"
            Target="{Binding RelativeSource={RelativeSource AncestorType=Window}}"
            Background="Green"
            Margin="10"
            MinLeft="{Binding Left, Source={x:Static SystemParameters.WorkArea}}"
            MinTop="{Binding Top, Source={x:Static SystemParameters.WorkArea}}"
            MaxRight="{Binding Right, Source={x:Static SystemParameters.WorkArea}}"
            MaxBottom="{Binding Bottom, Source={x:Static SystemParameters.WorkArea}}"
            >
            <TextBlock
                FontSize="14"
                HorizontalAlignment="Center"
                VerticalAlignment="Center"
                IsHitTestVisible="False"
                >
                <TextBlock.Text>
                    <MultiBinding StringFormat="Drag this element to move this window within the work area.&#10;[{0,7:0.0},{1,7:0.0}]">
                        <Binding Path="Target.Left" ElementName="windowWithinWorkAreaMover" />
                        <Binding Path="Target.Top" ElementName="windowWithinWorkAreaMover" />
                    </MultiBinding>
                </TextBlock.Text>
            </TextBlock>
        </n:DragMover>


        <!-- The Canvas area. -->
        <Border
            Grid.Column="0"
            Grid.ColumnSpan="2"
            Grid.Row="1"
            BorderBrush="Black"
            BorderThickness="1"
            Background="Honeydew"
            Margin="10"
            >
            <Canvas x:Name="canvas" ClipToBounds="True">
                <!-- The DragMover to move. -->
                <n:DragMover
                    x:Name="elementMover"
                    Canvas.Left="10"
                    Canvas.Top="10"
                    Width="330"
                    Height="60"
                    Background="Red"
                    Target="{Binding RelativeSource={RelativeSource Self}}"
                    >
                    <TextBlock
                        FontSize="14"
                        HorizontalAlignment="Center"
                        VerticalAlignment="Center"
                        IsHitTestVisible="False"
                        >
                        <TextBlock.Text>
                            <MultiBinding StringFormat="Drag this element to move.&#10;[{0,7:0.0},{1,7:0.0}]">
                                <Binding Path="(Canvas.Left)" ElementName="elementMover" />
                                <Binding Path="(Canvas.Top)" ElementName="elementMover" />
                            </MultiBinding>
                        </TextBlock.Text>
                    </TextBlock>
                </n:DragMover>

                
                <!-- The DragMover to move within the Canvas. -->
                <n:DragMover
                    x:Name="elementWithinCanvasMover"
                    Canvas.Left="350"
                    Canvas.Top="10"
                    Width="330"
                    Height="60"
                    Background="Green"
                    Target="{Binding RelativeSource={RelativeSource Self}}"
                    MinLeft="0"
                    MinTop="0"
                    MaxRight="{Binding ActualWidth, ElementName=canvas}"
                    MaxBottom="{Binding ActualHeight, ElementName=canvas}"
                    >
                    <TextBlock
                        FontSize="14"
                        HorizontalAlignment="Center"
                        VerticalAlignment="Center"
                        IsHitTestVisible="False"
                        >
                        <TextBlock.Text>
                            <MultiBinding StringFormat="Drag this element to move within the Canvas.&#10;[{0,7:0.0},{1,7:0.0}]">
                                <Binding Path="(Canvas.Left)" ElementName="elementWithinCanvasMover" />
                                <Binding Path="(Canvas.Top)" ElementName="elementWithinCanvasMover" />
                            </MultiBinding>
                        </TextBlock.Text>
                    </TextBlock>
                </n:DragMover>
            </Canvas>
        </Border>
    </Grid>
</Window>
